import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    meta: { title: '首页', icon: 'dashboard' },
    children: [
      {
        path: 'dashboard',
        name: 'Dashboard',
        component: () => import('@/views/dashboard/index'),
        meta: { title: '企业门户', icon: 'dashboard' }
      }
  //     {
  //       path: 'enterpriseInformation',
  //       name: 'enterpriseInformation',
  //       component: () => import('@/views/enterpriseInformation/index'),
  //       meta: { title: '企业资讯', icon: 'dashboard' }
  //     },
  //     {
  //       path: 'storeSetting',
  //       name: 'storeSetting',
  //       component: () => import('@/views/storeSetting/index'),
  //       meta: { title: '门店设置', icon: 'dashboard' }
  //     }
    ]
  },
  {
    path: '/product',
    component: Layout,
    meta: { title: '产品', icon: 'dashboard' },
    children: [
      {
        path: 'index',
        name: 'Product',
        component: () => import('@/views/product/index'),
        meta: { title: '编辑分类', icon: 'form' }
      },
      {
        path: 'add',
        name: 'Add',
        component: () => import('@/views/product/add/index'),
        meta: { title: '添加产品', icon: 'form' }
      },
      {
        path: 'list',
        name: 'List',
        component: () => import('@/views/product/list/index'),
        meta: { title: '产品列表', icon: 'form' }
      },
      {
        path: 'addSetting',
        name: 'AddSetting',
        component: () => import('@/views/product/addSetting/index'),
        meta: { title: '编辑产品', icon: 'form' },
        hidden: true
      }
    ]
  },
  {
    path: '/visitors',
    component: Layout,
    meta: { title: '访客', icon: 'dashboard' },
    children: [
      {
        path: 'analysis',
        name: 'Analysis',
        component: () => import('@/views/visitors/analysis/index'),
        meta: { title: '访客分析', icon: 'form' }
      },
      {
        path: 'index',
        name: 'Visitors',
        component: () => import('@/views/visitors/index'),
        meta: { title: '用户列表', icon: 'form' }
      }, 
      {
        path: 'chart',
        name: 'Chart',
        component: () => import('@/views/visitors/spread/index'),
        meta: { title: '传播图谱', icon: 'form' }
      },
      
    ]
    
  },
  
  {
    path: '/dynamic',
    component: Layout,
    meta: { title: '动态', icon: 'form' },
    children: [
      {
        path: 'index',
        name: 'dynamic',
        component: () => import('@/views/dynamic/index'),
        meta: { title: '动态', icon: 'form' },
      },
      {
        path: 'draft',
        name: 'Draft',
        component: () => import('@/views/dynamic/draft-box/index'),
        meta: { title: '草稿', icon: 'form' },
        
      },
      {
        path: 'send',
        name: 'SendDynamic',
        component: () => import('@/views/dynamic/send-dynamic/index'),
        meta: { title: '发布新', icon: 'form' },
        
      }
    ]
  },
  {
    path: '/auth-manage',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'authManage',
        component: () => import('@/views/auth-manage/index'),
        meta: { title: '人员', icon: 'form' }
      }
    ]
  },
  {
    path: '/message',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'message',
        component: () => import('@/views/message/index'),
        meta: { title: '消息', icon: 'form' }
      }
    ]
  },
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
